package com.example.hospital_208.service.impl;

import com.example.hospital_208.dao.UserRoleDao;
import com.example.hospital_208.po.UserRole;
import com.example.hospital_208.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired // 依赖注入 DAO
    private UserRoleDao userRoleDao;

    @Override
    public List<UserRole> listAllRoles() {
        return userRoleDao.selectAll();
    }

    @Override
    public UserRole getRoleById(String role_id) {
        return userRoleDao.selectById(role_id);
    }

    @Override
    public boolean addRole(UserRole userRole) {
        return userRoleDao.insert(userRole) > 0; // 插入成功返回 true
    }

    @Override
    public boolean updateRole(UserRole userRole) {
        return userRoleDao.update(userRole) > 0; // 更新成功返回 true
    }

    @Override
    public boolean deleteRole(String role_id) {
        return userRoleDao.deleteById(role_id) > 0; // 删除成功返回 true
    }
}